home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_UnarmedConvoy.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  5.4 KB  |  175 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. fsm Generic_UnarmedConvoy : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_UnarmedConvoy:
  12. //   Follows a path and but breaks off to run from enemies.
  13.  
  14. // NOTE: this script requires a CombatAI (or MechAI) to work properly!!!
  15.  
  16. //------------------------------------------------------------------
  17.  
  18.  
  19.  
  20. //------------------------------------------------------------------
  21. //     Constants
  22. //------------------------------------------------------------------
  23.  
  24.     const
  25.         #include_ <content\ABLScripts\mwconst.abi>
  26.  
  27. //------------------------------------------------------------------
  28. //     Types
  29. //------------------------------------------------------------------
  30.  
  31.     type
  32.         #include_ <content\ABLScripts\mwtype.abi>
  33.     
  34.  
  35. //------------------------------------------------------------------
  36. //     Variables
  37. //------------------------------------------------------------------
  38.  
  39.     var
  40.         static integer            fleeRange;            // At what range do I start running?
  41.         static integer            withdrawRange;        // After I've started to flee, at what range can I forget about my enemy and return to the convoy?
  42.         static integer            groupNumber;        // What's my group -- i.e. I will use GroupObjectID(groupNumber) to identify my group
  43.         static integer            speed;                // The speed at which I move along the path
  44.         static integer            formationType;        // What kind of formation am I in?
  45.         static integer            formationDensity;    // How densely are we packed?
  46.         static integer            path;                // My path
  47.         static integer            moveType;            // How I move along the path
  48.         static integer            fleeSpeed;            // How fast I flee
  49.  
  50.         static integer            piloting;            // Piloting skill
  51.         static integer            gunnery;            // Gunnery skill/chance to hit
  52.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  53.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  54.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  55.                                                     // and other things.  It indicates a general level of combat experience.
  56.         static integer            attackThrottle;        // My attack throttle
  57.  
  58.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  59.  
  60.         static integer             attackSound;        // The attack sound I play when I first attack
  61.         static integer             deathSound;            // The sound I play when I die
  62.         
  63.         static integer            mood;                // My default mood.
  64.  
  65.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  66.  
  67. //------------------------------------------------------------------
  68. //     Init: my initialization function
  69. //------------------------------------------------------------------
  70.  
  71. function Init;
  72.     code
  73.         // script-specific variables
  74.         fleeRange        = 500;
  75.         withdrawRange    = fleeRange * 3 / 2;
  76.         groupNumber        = 0;
  77.         path            = -1;
  78.         moveType        = move_nocycle;
  79.         speed            = 50;
  80.         formationType    = 1;
  81.         formationDensity= formtype_sparse;
  82.         fleeSpeed        = 600;
  83.  
  84.         takeOffDistance    = 150;
  85.  
  86.         // driver settings
  87.         piloting        = 50;
  88.         gunnery            = 30;
  89.         minDelay        = 1.5;
  90.         maxDelay        = 3.0;
  91.         eliteLevel        = 30;
  92.         attackThrottle    = 80;
  93.         isShotRadius    = 120;
  94.         attackSound        = -1; // no sound
  95.         deathSound        = -1; // no sound
  96.         mood            = NEUTRAL_START;
  97.  
  98. endfunction;
  99.  
  100. //------------------------------------------------------------------
  101. //    StartState: my initial state
  102. //------------------------------------------------------------------
  103.  
  104. state StartState;
  105.  
  106.     code
  107.         SetFiringDelay            (ME,minDelay,maxDelay);
  108.         SetIgnoreFriendlyFire    (ME,true);
  109.         SetIsShotRadius            (ME,isShotRadius);
  110.         SetEntropyMood            (ME,mood);
  111.         SetCurMood                (ME,mood);
  112.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  113.         SetAttackThrottle        (ME,attackThrottle);
  114.                 
  115.         if (orderTakeOff(takeOffDistance) == true) then
  116.             trans FollowPathState;
  117.         endif;
  118.  
  119. endstate;            
  120.  
  121. //------------------------------------------------------------------
  122. //    FollowPathState: follow our path, but keep an eye out for enemies
  123. //------------------------------------------------------------------
  124.  
  125. state FollowPathState;
  126.     code
  127.         if (FindEnemy(fleeRange,FT_DEFAULT)) then
  128.             trans FleeState;
  129.         endif;
  130.  
  131.         if (path <> -1) then
  132.             OrderFormationMove((groupobjectid(groupNumber)),path,speed,moveType,formationType,formationDensity,false);
  133.         else
  134.             OrderMoveLookOut;
  135.         endif;
  136. endstate;
  137.  
  138. //------------------------------------------------------------------
  139. //    FleeState: run away from my target
  140. //------------------------------------------------------------------
  141.  
  142. state FleeState;
  143.     code
  144.         if (LeaveAttackState(withdrawRange)) then
  145.             ClearMoveOrder(ME);
  146.             SetTarget(ME,NO_UNIT);
  147.             trans FollowPathState;
  148.         endif;
  149.  
  150.         if (attackSound <> -1) then    
  151.             PlaySoundOnce(attackSound);
  152.         endif;
  153.  
  154.         OrderMoveFlee(GetTarget(ME),fleeSpeed);
  155.  
  156. endstate;
  157.  
  158. //------------------------------------------------------------------
  159. //    DeadState: OK, I kicked the bucket.
  160. //------------------------------------------------------------------
  161.  
  162. state DeadState;
  163.     code
  164.         if (deathSound <> -1) then    
  165.             PlaySoundOnce(deathSound);
  166.         endif;        
  167.  
  168.         orderDie;
  169.  
  170. endstate;
  171.  
  172.  
  173. endfsm.
  174.  
  175.